<?php
	if (!empty($this->validationErrors) && !empty($this->validationErrors['User']))
	{
		echo "<div style=\"padding-left: 165px; color: red; padding-bottom: 5px;\">\n\t<ul>";
		foreach ($this->validationErrors['User'] as $key => $value) {
			echo "\t\t<li>$value</li>";
		}
		echo "\t</ul>\n</div>";
	}
//	echo $this->validationErrors['User']['firstname']
?>
<form id="UserEditForm" method="post" action="/users/edit/<?=$this->data['User']['id']?>">
	<input type="hidden" name="data[User][id]" value="<?=$this->data['User']['id']?>" id="UserId" />
	<fieldset style="padding: 5px 0px">
      <legend style="margin-left:15px; padding: 0px 3px 3px 0px; font-size: 10pt"><strong>Thông tin nhân sự</strong></legend>
	  <div style="margin-top: 10px">
		<div class="label" style="float:left; width: 130px; text-align: right; padding-right: 3px; font-weight: bold">Tên truy cập:</div>
		<div style="float:left; width: 500px">
			<input name="data[User][username]" value="<?=$this->data['User']['username']?>" style="width: 266px" class="textbox" type="text" maxlength="60" value="" id="UserUsername" />
		</div>
		<div style="clear: both"></div>
	  </div>
 	  <div style="margin-top: 2px">
		<div class="label" style="float:left; width: 130px; text-align: right; padding-right: 3px; font-weight: bold">Mật khẩu:</div>
		<div style="float:left; width: 300px">
			<input name="data[User][password]" value="" style="width: 266px" class="textbox" type="password" maxlength="120" value="" id="UserPassword" />
		</div>
		<div style="clear: both"></div>
	  </div>
	  <div style="margin-top: 2px">
		<div class="label" style="float:left; width: 130px; text-align: right; padding-right: 3px; font-weight: bold">Nhân viên:</div>
		<div style="float:left; width: 300px">
			<select name="data[User][employee_id]" style="width: 266px" class="textbox" id="UserEmployee_id" >
				<option value="0" selected="selected">--- Chọn một nhân viên ---</option>
<?php		
			foreach ($employees as $employee) {
				if ($employee['Employee']['id'] == $this->data['User']['employee_id']) {
?>
				<option selected="selected" value="<?=$employee['Employee']['id']?>"><?=$employee['Employee']['firstname'] ?> <?=$employee['Employee']['middlename'] ?> <?=$employee['Employee']['lastname'] ?></option>
<?php 		
				} else {
?>
				<option value="<?=$employee['Employee']['id']?>"><?=$employee['Employee']['firstname'] ?> <?=$employee['Employee']['middlename'] ?> <?=$employee['Employee']['lastname'] ?></option>
<?php 			
				}	
			}	// End For
?>
			</select>
		</div>
		<div style="clear: both"></div>
	  </div>
   	  <div style="margin-top: 2px">
		<div class="label" style="float:left; width: 130px; text-align: right; padding-right: 3px; font-weight: bold">Hoạt động:</div>
		<div style="float:left; width: 300px">
<?php
			if ($this->data['User']['status'] == 1)
			{
?>
				<input type="checkbox" name="data[User][status]" id="UserStatus" checked="checked" style="padding-top: 5px">
<?				
			} else {
?>
				<input type="checkbox" name="data[User][status]" id="UserStatus" style="padding-top: 5px">
<?				
			}
?>
		</div>
		<div style="clear: both"></div>
	  </div>
   </fieldset>
	<div style="margin-top: 12px; margin-left: 135px">
		<input type="submit" value="Cập nhật" class="button" /><input type="button" value="Trở về" class="button" style="margin-left: 15px" onclick="javascript: window.location='/users'" />
	</div>
</form>